﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using CustomsSystem.BLL;
using CustomsSystem.Model;

namespace WEB.Code
{
    public partial class ChanceCode : System.Web.UI.Page
    {
        DataSet ds;
        CodeManage BLL = new CodeManage();

        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
                //获取代码主页转过来的代码ID
                if (Request.QueryString["ID"] != "")
                {
                    int codeID = Convert.ToInt32(Request.QueryString["ID"]);
                    string codeType = Session["codeType"].ToString();
                    string codeTypeName = Session["codeTypeName"].ToString();
                    HiddenField1.Value = codeType;
                    Info_code myCont = BLL.GetModel(codeType, codeID);

                    lbType.Text = codeTypeName;
                    lbNO.Text = myCont.codeID.ToString();
                    tbCode.Text = myCont.codeName.ToString();

                    /**/
                    //Session["updatecodeType"] = codeType;
                }
            }
        }
        //确定修改
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (tbCode.Text.Trim() != "")
            {
                Info_code info_code = new Info_code();
                info_code.codeID = Convert.ToInt32(lbNO.Text);
                info_code.codeType = HiddenField1.Value;
                info_code.codeName = tbCode.Text;

                BLL.Update(info_code);
                Response.Write("<script>alert('修改成功')</script>");
                return;
            }
            else
            {
                Response.Write("<script>alert('请输入名称')</script>");
                return;
            }
        }
        //返回到主页面
        protected void Button2_Click(object sender, EventArgs e)
        {
            string codeID = Session["codeType"].ToString();
            Response.Redirect("codeIndex.aspx?AddType=" + codeID);
        }
    }
}